package main.utils;

import java.util.Random;

public class TrapsFactory {
    public static final int TRAP_WIDTH = 5;
    public static final int TRAP_HEIGHT = 10;
    private static Random random = new Random();

    @SuppressWarnings({"ConstantConditions", "ConstantIfStatement"})
    public static boolean[][] getRandomTrap() {
        int trapChance = random.nextInt(200);
        if (trapChance % 10 == 0) {
            return deadRiff();
        }
        if (trapChance % 7 == 0) {
            return getZiggo();
        }
        if (trapChance % 5 == 0) {
            return getLine();
        }
        if (trapChance % 3 == 0) {
            return getTriple();
        }
        return getSingle();
    }

    private static boolean[][] getSingle() {
        boolean[][] trap = new boolean[TRAP_WIDTH][TRAP_HEIGHT];
        trap[0][random.nextInt(TRAP_HEIGHT)] = true;
        return trap;
    }

    private static boolean[][] getTriple() {
        boolean[][] trap = new boolean[TRAP_WIDTH][TRAP_HEIGHT];
        trap[0][0] = true;
        trap[1][1] = true;
        trap[2][2] = true;
        return trap;
    }

    private static boolean[][] getZiggo() {
        boolean[][] trap = new boolean[TRAP_WIDTH][TRAP_HEIGHT];
        trap[0][0] = true;
        trap[1][1] = true;
        trap[2][2] = true;
        trap[3][3] = true;
        trap[4][4] = false;
        trap[3][6] = true;
        trap[2][7] = true;
        trap[1][8] = true;
        return trap;
    }

    private static boolean[][] deadRiff() {
        boolean[][] trap = new boolean[TRAP_WIDTH][TRAP_HEIGHT];
        trap[1][0] = true;
        trap[0][1] = true;
        trap[3][4] = true;
        trap[1][3] = true;
        trap[1][6] = true;
        trap[0][5] = true;
        trap[4][2] = true;
        trap[4][5] = true;
        trap[4][7] = true;
        trap[1][9] = true;
        return trap;
    }

    private static boolean[][] getLine() {
        boolean[][] trap = new boolean[TRAP_WIDTH][TRAP_HEIGHT];
        for (int trapRow = 0; trapRow < TRAP_HEIGHT; trapRow++) {
            trap[0][trapRow]=true;
        }
        trap[0][random.nextInt(TRAP_HEIGHT)] = false;
        return trap;
    }

}
